package com.seqb.common;

import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author lilinshen
 * @title 树
 * @description 请填写相关描述
 * @date 2019/11/12
 */
@Data
public class TreeNew<T> {
    /**
     * 节点ID
     */
    private String id;
    /**
     * cardId
     */
    private String carId;
    /**
     * 显示节点文本
     */
    private String text;
    /**
     * 节点状态，open closed
     */
    private Map<String, Object> state;
    /**
     * 节点是否被选中 true false
     */
    private boolean checked = false;
    /**
     * 节点属性
     */
    private Map<String, Object> attributes;
    /**
     * 节点的子节点
     */
    private List<TreeNew<T>> children = new ArrayList<TreeNew<T>>();
    /**
     * 父ID
     */
    private String parentId;
    /**
     * 父名称
     */
    private String parentName;
    /**
     * 是否有父节点
     */
    private boolean hasParent = false;
    /**
     * 是否有子节点
     */
    private boolean hasChildren = false;

    public TreeNew() {
        super();
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    public TreeNew(String id, String text, Map<String, Object> state, boolean checked, Map<String, Object> attributes,
                   List<TreeNew<T>> children, boolean isParent, boolean isChildren, String parentId) {
        super();
        this.id = id;
        this.text = text;
        this.state = state;
        this.checked = checked;
        this.attributes = attributes;
        this.children = children;
        this.hasParent = isParent;
        this.hasChildren = isChildren;
        this.parentId = parentId;
    }
}